'use strict';

const Service = require('egg').Service;

class MongoService extends Service {
  async tools() {
    // await this.ctx.model.UserInfo.insertMany([{
    //   username:'123123',
    //   userpassword:"123123"
    // },{
    //   username:'123124',
    //   userpassword:"1231234"
    // }]);  // 插入多条文档
    // const result = await this.ctx.model.UserInfo.deleteMany({__v:"0"}) // 删除一条文档/
    // await this.ctx.model.UserInfo.updateMany({username:'123123'},{$set:{userpassword:"456"}})
    // 修改一条文档
    // const result = await this.ctx.model.user.updateOne({age: {$gt: 18}}, { isAdult: true });
    // 查询满足条件所有文档
    const resultdata = await this.ctx.model.UserInfo.find({});
    return resultdata;
  }
}
module.exports = MongoService;

